package com.ljlobserv.demo.dao;

import com.ljlobserv.demo.entity.User;
import com.ljlobserv.demo.entity.UserRecord;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * ClassName：UserRecordImpl
 * Description：
 * Create by Administrator
 * Date：2020/8/25 0025 10:30
 */
public class UserRecordImpl implements UserRecodeDao {
    private List<UserRecord> list = new ArrayList<UserRecord>();
    private Long id = 1L;

    public void insert(Long uid) {
        UserRecord userRecord = new UserRecord();
        userRecord.setCreateTime(new Date());
        userRecord.setId(id);
        userRecord.setUid(uid);
        list.add(userRecord);
        id++;
        System.out.println("UserRecordImpl执行添加数据..."+userRecord);
    }

    public void delete(long id) {
        for (int i = 0; i < list.size(); i++) {
            UserRecord userRecord = list.get(i);
            if(userRecord.getId() == id){
                list.remove(i);
                System.out.println("UserRecordImpl执行删除数据..."+userRecord);
            }
        }
    }
}
